<?php
/**
 * Created by PhpStorm.
 * User: yu
 * Date: 2017/1/9
 * Time: 下午4:58
 */

namespace Common\Model;


class GoodsListModel extends BaseModel
{
	protected $pk = 'glid';
	protected $tableName = 'goods_list';
	protected $_validate = [
		['glnumber','require','货号必填',3,3],
		['inventory','require','库存必填',3,3]
	];

	/**
	 * 添加货品
	 */
	public function addGoodsList(){
		if(!$this->create()){
			return ['status'=>'error','message'=>$this->getError()];
		}
		//验证是否有属性没有选择，影响货品入库
		foreach ($_POST['combine'] as $k=>$v){
			if(!$v){
				return ['status'=>'error','message'=>'属性必选'];
			}
		}
		//
		$_POST['combine'] = implode(',',$_POST['combine']);
		return $this->store($_POST);

	}
}